package org.dk.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import org.dk.domain.DataResult;
import org.dk.em.DataResultEnum;
import org.dk.pojo.TbItemCat;
import org.dk.service.TbItemCatService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("itemCatController")
@Controller
public class ItemCatController {
    @Reference
    private TbItemCatService itemCatService;

    @RequestMapping("selectByParentId")
    @ResponseBody
    public DataResult selectByParentId(Long parentId){
        try {
            List<TbItemCat> itemList = itemCatService.selectByParentId(parentId);
            return DataResult.buildDataResult(DataResultEnum.SUCCESS).setData(itemList);
        }catch (Exception e){
            e.printStackTrace();
         return DataResult.buildDataResult(DataResultEnum.ERROR);
        }
    }
}
